Shader "cyUrp/Lit"
{
    Properties
    {
        _BaseMap("Texture", 2D) = "white" {}
        _BaseColor("Base Color", Color) = (0.5,0.5, 0.5, 1)
        
        _Cutoff("Alpha CutOff", Range(0,1)) = 0.5
        [Toggle(_CLIPPING)] _Clipping("Alpha Clipping", float) = 0
        [Toggle(_RECEIVE_SHADOWS)] _ReceiveShadows("Receive Shadows", float) =1
        [KeywordEnum(On,Clip, Dither, Off)] _Shadows("Shadows", float) = 0
        [Toggle(_MASK_MAP)]_MaskMapToggle("Mask Map", float) = 0
        [NoScaleOffset]_MaskMap("Mask (MODS)", 2d) = "white"{}
        _Metallic("Metallic", Range(0,1)) = 0
        _Occlusion("Occlusion", Range(0,1)) = 1
        _Smoothness("Smoothness", Range(0,1)) = 0.5
        _Fresnel("Fresnel", Range(0,1)) = 1
	[Toggle(_NORMAL_MAP)]_NormalMapToggle("Normal Map", float) = 0
        [NoScaleOffset]_NormalMap("Normals", 2d) = "bump" {}
        _NormalScale("Normal Scale", Range(0,1)) = 1
        
        [NoScaleOffset] _EmissionMap("Emission", 2D) = "white" {}
        [HDR] _EmissionColor("Emission Color", Color) = (0,0,0,0)
        [Toggle(_DETAIL_MAP)]_DetailMapToggle("Detail Maps", float) = 0
        _DetailMap("Details", 2d) = "linearGrey" {}
        [NoScaleOffset]_DetailNormalMap("Detail Normals", 2d) = "bump" {}
        _DetailAlbedo("Detail Albedo", Range(0,1)) = 1
        _DetailSmoothness("Detail smoothness", Range(0,1)) = 1
        _DetailNormalScale("Detail Normal Scale", Range(0,1)) = 1
	[Toggle(_PREMULTIPLY_ALPHA)] _PremulAlpha("Premultiply Alpha", float) = 0
        
	[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("Src Blend", float) = 1
        [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Dst Blend", float) = 0
        [Enum(Off,0, On, 1)] _ZWrite("Z Write", float) = 1
        [HideInInspector] _MainTex("Texture for Lightmap", 2D) = "white" {}
        [HideInInspector] _Color("Color for Lightmap", Color) = (0.5,0.5,0.5,1.0)
     }
    SubShader
    { 
        HLSLINCLUDE
        #include "./Include/Common.hlsl"
        #include "./Include/LitInput.hlsl"
        ENDHLSL

        pass
        {
            Tags { "LightMode" = "CustomLit"}
            Blend [_SrcBlend] [_DstBlend]
            ZWrite [_ZWrite]
            HLSLPROGRAM
            #pragma target 3.5
            #pragma shader_feature _CLIPPING             
	    #pragma shader_feature _RECEIVE_SHADOWS
            #pragma shader_feature _PREMULTIPLY_ALPHA
	    #pragma shader_feature _MASK_MAP
            #pragma shader_feature _NORMAL_MAP
            #pragma shader_feature _DETAIL_MAP
		

            #pragma multi_compile _ _DIRECTIONAL_PCF3 _DIRECTIONAL_PCF5 _DIRECTIONAL_PCF7
            #pragma multi_compile _ _OTHER_PCF3 _OTHER_PCF5 _OTHER_PCF7
            #pragma multi_compile _ _CASCADE_BLEND_SOFT _CASCADE_BLEND_DITHER
            #pragma multi_compile _ _SHADOW_MASK_ALWAYS _SHADOW_MASK_DISTANCE
            #pragma multi_compile _ _LIGHTS_PER_OBJECT
            #pragma multi_compile _ LIGHTMAP_ON
	    #pragma multi_compile _ LOD_FADE_CROSSFADE 
            
            #pragma multi_compile_instancing 
            #pragma vertex LitPassVertex
            #pragma fragment LitPassFragment 
            #include "./Include/LitPass.hlsl"
            ENDHLSL 
        }
        pass
        {
            Tags { "LightMode" = "ShadowCaster"}
            ColorMask 0
            HLSLPROGRAM
            #pragma target 3.5
            #pragma shader_feature _ _SHADOWS_CLIP _SHADOWS_DITHER
	    #pragma multi_compile _ LOD_FADE_CROSSFADE
	    #pragma multi_compile_instancing
	    #pragma vertex ShadowCasterPassVertex
	    #pragma fragment ShadowCasterPassFragment 
	    #include "./Include/ShadowCasterPass.hlsl"
            ENDHLSL
        }
       
       Pass {
			Tags {
				"LightMode" = "Meta"
			}

			Cull Off

			HLSLPROGRAM
			#pragma target 3.5
			#pragma vertex MetaPassVertex
			#pragma fragment MetaPassFragment
            		#include "./Include/MetaPass.hlsl"
			ENDHLSL
		}
    }
    CustomEditor "CustomShaderGUI"
}